import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    enabledCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '/editMenu',
    component: Layout ,
    redirect:'/sys/menu/editMenu',
    children: [{
      path: '/sys/menu/editMenu',
      component: _import('sys/menu/addOrUpdate'),
      hidden: true,
      name: 'editMenu',
      title: 'editMenu',
    }]
  },
  {
    path: '/assignRoles',
    component: Layout ,
    redirect:'/sys/user/assignRoles',
    children: [{
      path: '/sys/user/assignRoles',
      component: _import('sys/user/assignRoles'),
      hidden: true,
      name: 'assignRoles',
      title: 'assignRoles',
    }]
  },
  {
    path: '/assignDataScope',
    component: Layout ,
    redirect:'/sys/user/assignDataScope',
    children: [{
      path: '/sys/user/assignDataScope',
      component: _import('sys/user/assignDataScope'),
      hidden: true,
      name: 'assignDataScope',
      title: 'assignDataScope',
    }]
  },
  {
    path: '/editDepartment',
    component: Layout ,
    redirect:'/sys/department/editDepartment',
    children: [{
      path: '/sys/department/editDepartment',
      component: _import('sys/department/addOrUpdate'),
      hidden: true,
      name: 'editDepartment',
      title: 'editDepartment',

    }]
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    name:'dashboard',
    icon: 'dashboard',
    title:'dashboard',
    disabled:true,
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      title: 'dashboard',
      icon: 'dashboard',
      enabledCache: true,
      disabled:true

    }]
  },
  {
    path: '/documentation',
    component: Layout,
    redirect: '/documentation/index',
    name: 'documentation',
    icon: 'documentation',
    title:'documentation',
    disabled:true,
    children: [{
      path: 'index',
      component: _import('documentation/index'),
      name: 'documentation',
      title: 'documentation',
      icon: 'documentation',
      enabledCache: true,
      disabled:true
    }]
  }
/*  {
    path: '/permission',
    component: Layout,
    redirect: '/permission/index',
    //  meta: { roles: ['admin'] }, // you can set roles in root nav
    title: 'permission',
    icon: 'lock',
    name:'permission',
    children: [{
      path: 'index',
      component: _import('permission/index'),
      name: 'permission',

      title: 'permission',
      icon: 'lock',


    }]
  },*/

  /*{
    path: '/icon',
    component: Layout,
    title: 'icons',
    icon: 'icon',
    name: 'icons',
    children: [{
      path: 'index',
      component: _import('svg-icons/index'),
      name: 'icons',
      title: 'icons', icon: 'icon', enabledCache: true
    }]
  },

  {
    path: '/components',
    component: Layout,
    redirect: 'noredirect',
    name: 'component-demo',
    title: 'components',
    icon: 'component',
    /!*   meta: {
     title: 'components',
     icon: 'component'
     },*!/
    children: [
      { path: 'tinymce', component: _import('components-demo/tinymce'), name: 'tinymce-demo',title: 'tinymce' },
      { path: 'markdown', component: _import('components-demo/markdown'), name: 'markdown-demo',  title: 'markdown' },
      { path: 'json-editor', component: _import('components-demo/jsonEditor'), name: 'jsonEditor-demo', title: 'jsonEditor' },
      { path: 'dnd-list', component: _import('components-demo/dndList'), name: 'dndList-demo', title: 'dndList' },
      { path: 'splitpane', component: _import('components-demo/splitpane'), name: 'splitpane-demo',title: 'splitPane' },
      { path: 'avatar-upload', component: _import('components-demo/avatarUpload'), name: 'avatarUpload-demo', title: 'avatarUpload'},
      { path: 'dropzone', component: _import('components-demo/dropzone'), name: 'dropzone-demo',title: 'dropzone'},
      { path: 'sticky', component: _import('components-demo/sticky'), name: 'sticky-demo', title: 'sticky'},
      { path: 'count-to', component: _import('components-demo/countTo'), name: 'countTo-demo',title: 'countTo' },
      { path: 'mixin', component: _import('components-demo/mixin'), name: 'componentMixin-demo',title: 'componentMixin'},
      { path: 'back-to-top', component: _import('components-demo/backToTop'), name: 'backToTop-demo', title: 'backToTop'},
      { path: 'drag-dialog', component: _import('components-demo/dragDialog'), name: 'dragDialog-demo', title: 'dragDialog'}
    ]
  },

  {
    path: '/charts',
    component: Layout,
    redirect: 'noredirect',
    name: 'charts',
    icon: 'chart',
    title:'charts',
    /!* meta: {
     title: 'charts',
     icon: 'chart'
     },*!/
    children: [
      { path: 'keyboard', component: _import('charts/keyboard'), name: 'keyboardChart',title: 'keyboardChart', enabledCache: true},
      { path: 'line', component: _import('charts/line'), name: 'lineChart', title: 'lineChart', enabledCache: true},
      { path: 'mixchart', component: _import('charts/mixChart'), name: 'mixChart',title: 'mixChart', enabledCache: true}
    ]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table/complex-table',
    name: 'example',
    icon: 'example',
    title:'example',
    /!* meta: {
     title: 'example',
     icon: 'example'
     },*!/
    children: [
      {
        path: '/example/table',
        component: _import('example/table/index'),
        redirect: '/example/table/complex-table',
        name: 'Table',
        icon: 'table',
        title: 'Table',
        /!*   meta: {
         title: 'Table',
         icon: 'table'
         },*!/
        children: [
          { path: 'dynamic-table', component: _import('example/table/dynamicTable/index'), name: 'dynamicTable',title: 'dynamicTable' },
          { path: 'drag-table', component: _import('example/table/dragTable'), name: 'dragTable', title: 'dragTable' },
          { path: 'inline-edit-table', component: _import('example/table/inlineEditTable'), name: 'inlineEditTable', title: 'inlineEditTable' },
          { path: 'tree-table', component: _import('example/table/treeTable/treeTable'), name: 'treeTableDemo', title: 'treeTable' },
          { path: 'custom-tree-table', component: _import('example/table/treeTable/customTreeTable'), name: 'customTreeTableDemo',title: 'customTreeTable' },
          { path: 'complex-table', component: _import('example/table/complexTable'), name: 'complexTable', title: 'complexTable' }
        ]
      },
      { path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'tab', title: 'tab'}
    ]
  },

  {
    path: '/form',
    component: Layout,
    redirect: 'noredirect',
    name: 'form',
    icon: 'form',
    title: 'form',
    /!*  meta: {
     title: 'form',
     icon: 'form'
     },*!/
    children: [
      { path: 'create-form', component: _import('form/create'), name: 'createForm', title: 'createForm', icon: 'table' },
      { path: 'edit-form', component: _import('form/edit'), name: 'editForm', title: 'editForm', icon: 'table' }
    ]
  },

  {
    path: '/error',
    component: Layout,
    redirect: 'noredirect',
    name: 'errorPages',
    title: 'errorPages',
    icon: '404',
    /!*  meta: {
     title: 'errorPages',
     icon: '404'
     },*!/
    children: [
      { path: '401', component: _import('errorPage/401'), name: 'page401',  title: 'page401', enabledCache: true },
      { path: '404', component: _import('errorPage/404'), name: 'page404', title: 'page404', enabledCache: true }
    ]
  },

  {
    path: '/error-log',
    component: Layout,
    redirect: 'noredirect',
    title: 'errorLog',
    icon: 'bug',
    name: 'errorLog',
    children: [{ path: 'log', component: _import('errorLog/index'), name: 'errorLog',
      title: 'errorLog', icon: 'bug' }]
  },

  {
    path: '/excel',
    component: Layout,
    redirect: '/excel/export-excel',
    name: 'excel',
    title: 'excel',
    icon: 'excel',
    /!*  meta: {
     title: 'excel',
     icon: 'excel'
     },*!/
    children: [
      { path: 'export-excel', component: _import('excel/exportExcel'), name: 'exportExcel', title: 'exportExcel' },
      { path: 'export-selected-excel', component: _import('excel/selectExcel'), name: 'selectExcel', title: 'selectExcel' },
      { path: 'upload-excel', component: _import('excel/uploadExcel'), name: 'uploadExcel', title: 'uploadExcel' }
    ]
  },

  {
    path: '/zip',
    component: Layout,
    redirect: '/zip/download',
    alwaysShow: true,
    title: 'zip', icon: 'zip',
    // meta: { title: 'zip', icon: 'zip' },
    name: '',
    children: [{ path: 'download', component: _import('zip/index'), name: 'exportZip', title: 'exportZip'}]
  },

  {
    path: '/theme',
    component: Layout,
    redirect: 'noredirect',
    children: [{ path: 'index', component: _import('theme/index'), name: 'theme', title: 'theme', icon: 'theme'}]
  },

  {
    path: '/clipboard',
    component: Layout,
    redirect: 'noredirect',
    /!*  name: 'clipboardDemo',
     title: 'clipboardDemo',
     icon: 'clipboard',*!/
    children: [{ path: 'index', component: _import('clipboard/index'), name: 'clipboardDemo',title: 'clipboardDemo', icon: 'clipboard'}]
  },

  {
    path: '/i18n',
    component: Layout,
    name: 'i18n',
    title: 'i18n', icon: 'international',
    children: [{ path: 'index', component: _import('i18n-demo/index'), name: 'i18n', title: 'i18n', icon: 'international'}]
  },
*/
  /*{ path: '*', redirect: '/404', hidden: true }*/
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [

  {
    path: '/icon',
    component: Layout,
    title: 'icons',
    icon: 'icon',
    name: 'icons',
    children: [{
      path: 'index',
      component: _import('svg-icons/index'),
      name: 'icons',
      title: 'icons', icon: 'icon', enabledCache: true
    }]
  },

  {
    path: '/components',
    component: Layout,
    redirect: 'noredirect',
    name: 'component-demo',
    title: 'components',
    icon: 'component',
 /*   meta: {
      title: 'components',
      icon: 'component'
    },*/
    children: [
      { path: 'tinymce', component: _import('components-demo/tinymce'), name: 'tinymce-demo',title: 'tinymce' },
      { path: 'markdown', component: _import('components-demo/markdown'), name: 'markdown-demo',  title: 'markdown' },
      { path: 'json-editor', component: _import('components-demo/jsonEditor'), name: 'jsonEditor-demo', title: 'jsonEditor' },
      { path: 'dnd-list', component: _import('components-demo/dndList'), name: 'dndList-demo', title: 'dndList' },
      { path: 'splitpane', component: _import('components-demo/splitpane'), name: 'splitpane-demo',title: 'splitPane' },
      { path: 'avatar-upload', component: _import('components-demo/avatarUpload'), name: 'avatarUpload-demo', title: 'avatarUpload'},
      { path: 'dropzone', component: _import('components-demo/dropzone'), name: 'dropzone-demo',title: 'dropzone'},
      { path: 'sticky', component: _import('components-demo/sticky'), name: 'sticky-demo', title: 'sticky'},
      { path: 'count-to', component: _import('components-demo/countTo'), name: 'countTo-demo',title: 'countTo' },
      { path: 'mixin', component: _import('components-demo/mixin'), name: 'componentMixin-demo',title: 'componentMixin'},
      { path: 'back-to-top', component: _import('components-demo/backToTop'), name: 'backToTop-demo', title: 'backToTop'},
      { path: 'drag-dialog', component: _import('components-demo/dragDialog'), name: 'dragDialog-demo', title: 'dragDialog'}
    ]
  },

  {
    path: '/charts',
    component: Layout,
    redirect: 'noredirect',
    name: 'charts',
    icon: 'chart',
    title:'charts',
   /* meta: {
      title: 'charts',
      icon: 'chart'
    },*/
    children: [
      { path: 'keyboard', component: _import('charts/keyboard'), name: 'keyboardChart',title: 'keyboardChart', enabledCache: true},
      { path: 'line', component: _import('charts/line'), name: 'lineChart', title: 'lineChart', enabledCache: true},
      { path: 'mixchart', component: _import('charts/mixChart'), name: 'mixChart',title: 'mixChart', enabledCache: true}
    ]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table/complex-table',
    name: 'example',
    icon: 'example',
    title:'example',
   /* meta: {
      title: 'example',
      icon: 'example'
    },*/
    children: [
      {
        path: '/example/table',
        component: _import('example/table/index'),
        redirect: '/example/table/complex-table',
        name: 'Table',
        icon: 'table',
        title: 'Table',
     /*   meta: {
          title: 'Table',
          icon: 'table'
        },*/
        children: [
          { path: 'dynamic-table', component: _import('example/table/dynamicTable/index'), name: 'dynamicTable',title: 'dynamicTable' },
          { path: 'drag-table', component: _import('example/table/dragTable'), name: 'dragTable', title: 'dragTable' },
          { path: 'inline-edit-table', component: _import('example/table/inlineEditTable'), name: 'inlineEditTable', title: 'inlineEditTable' },
          { path: 'tree-table', component: _import('example/table/treeTable/treeTable'), name: 'treeTableDemo', title: 'treeTable' },
          { path: 'custom-tree-table', component: _import('example/table/treeTable/customTreeTable'), name: 'customTreeTableDemo',title: 'customTreeTable' },
          { path: 'complex-table', component: _import('example/table/complexTable'), name: 'complexTable', title: 'complexTable' }
        ]
      },
      { path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'tab', title: 'tab'}
    ]
  },

  {
    path: '/form',
    component: Layout,
    redirect: 'noredirect',
    name: 'form',
    icon: 'form',
    title: 'form',
  /*  meta: {
      title: 'form',
      icon: 'form'
    },*/
    children: [
      { path: 'create-form', component: _import('form/create'), name: 'createForm', title: 'createForm', icon: 'table' },
      { path: 'edit-form', component: _import('form/edit'), name: 'editForm', title: 'editForm', icon: 'table' }
    ]
  },

  {
    path: '/error',
    component: Layout,
    redirect: 'noredirect',
    name: 'errorPages',
    title: 'errorPages',
    icon: '404',
  /*  meta: {
      title: 'errorPages',
      icon: '404'
    },*/
    children: [
      { path: '401', component: _import('errorPage/401'), name: 'page401',  title: 'page401', enabledCache: true },
      { path: '404', component: _import('errorPage/404'), name: 'page404', title: 'page404', enabledCache: true }
    ]
  },

  {
    path: '/error-log',
    component: Layout,
    redirect: 'noredirect',
    title: 'errorLog',
    icon: 'bug',
    name: 'errorLog',
    children: [{ path: 'log', component: _import('errorLog/index'), name: 'errorLog',
      title: 'errorLog', icon: 'bug' }]
  },

  {
    path: '/excel',
    component: Layout,
    redirect: '/excel/export-excel',
    name: 'excel',
    title: 'excel',
    icon: 'excel',
  /*  meta: {
      title: 'excel',
      icon: 'excel'
    },*/
    children: [
      { path: 'export-excel', component: _import('excel/exportExcel'), name: 'exportExcel', title: 'exportExcel' },
      { path: 'export-selected-excel', component: _import('excel/selectExcel'), name: 'selectExcel', title: 'selectExcel' },
      { path: 'upload-excel', component: _import('excel/uploadExcel'), name: 'uploadExcel', title: 'uploadExcel' }
    ]
  },

  {
    path: '/zip',
    component: Layout,
    redirect: '/zip/download',
    alwaysShow: true,
    title: 'zip', icon: 'zip',
   // meta: { title: 'zip', icon: 'zip' },
    name: 'exportZip',
    children: [{ path: 'download', component: _import('zip/index'), name: 'exportZip', title: 'exportZip'}]
  },

  {
    path: '/theme',
    component: Layout,
    redirect: 'noredirect',
    children: [{ path: 'index', component: _import('theme/index'), name: 'theme', title: 'theme', icon: 'theme'}]
  },

  {
    path: '/clipboard',
    component: Layout,
    redirect: 'noredirect',
  /*  name: 'clipboardDemo',
    title: 'clipboardDemo',
    icon: 'clipboard',*/
    children: [{ path: 'index', component: _import('clipboard/index'), name: 'clipboardDemo',title: 'clipboardDemo', icon: 'clipboard'}]
  },

  {
    path: '/i18n',
    component: Layout,
    name: 'i18n',
    title: 'i18n', icon: 'international',
    children: [{ path: 'index', component: _import('i18n-demo/index'), name: 'i18n', title: 'i18n', icon: 'international'}]
  },

  { path: '*', redirect: '/404', hidden: true }
]
